﻿using Hawksoft.Services;
using System;
using System.Collections.Generic;

namespace Hawksoft.Data
{
    /// <summary>
    ///   Contains static extension methods for DbField and Meta objects.</summary>
    public static class ServiceRequestExtensions
    {
        public static TRequest IncludeField<TRequest>(this TRequest request, Field field) 
            where TRequest : ServiceRequest, IIncludeExcludeColumns
        {
            request.IncludeColumns = request.IncludeColumns ?? new HashSet<string>(StringComparer.OrdinalIgnoreCase);
            request.IncludeColumns.Add(field.PropertyName ?? field.Name);
            return request;
        }
    }
}